package com.umer.pinban.inventorymanagement;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.common.base.activity.BaseActivity;
import com.common.bean.InfoResult;
import com.common.bean.MsgBean;
import com.common.bean.UserInfo;
import com.common.ui.barlibrary.ImmersionBar;
import com.common.ui.loadsir.callback.EmptyCallback;
import com.common.ui.loadsir.callback.ErrorCallback;
import com.common.ui.loadsir.callback.NoNetCallback;
import com.common.ui.recycleview.listener.DataStateListener;
import com.common.ui.recycleview.listener.OptListener;
import com.umer.pinban.AppHolder;
import com.umer.pinban.R;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 库存管理
 */
public class InventoryManagementActivity extends BaseActivity implements OptListener, DataStateListener {

    @BindView(R.id.linear_back)
    LinearLayout linearBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.ll_content)
    LinearLayout llContent;
    private UserInfo userInfo;

    @Override
    public View isSupportLoadSirEnabled() {
        return llContent;
    }

    @Override
    public boolean isImmersionBarEnabled() {
        return true;
    }

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this)
                //是否可以修改导航栏颜色，默认为true
                .navigationBarEnable(true)
                //导航栏颜色，不写默认黑色
                .navigationBarColor(R.color.barcolor)
                .statusBarColor(R.color.colorPrimary)
                //解决状态栏和布局重叠问题，任选其一，默认为false，当为true时一定要指定statusBarColor()，不然状态栏为透明色，还有一些重载方法
                .fitsSystemWindows(true)
                .init();
    }

    @Override
    public boolean isSupportSwipeBackEnabled() {
        return false;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public int getLayoutResId() {
        return R.layout.activity_inventory_management;
    }

    @Override
    public void init() {
        userInfo = AppHolder.getInstance().getUserInfo();
    }

    @Override
    public void loadData() {
    }

    @OnClick({R.id.linear_back})
    public void OnClick(View view) {
        switch (view.getId()) {
            case R.id.linear_back:
                finish();
                break;
            default:
                break;
        }
    }

    @Override
    public void onOptClick(View view, Object object) {
        switch (view.getId()) {
        }
    }

    @Override
    public void handlerMeg(MsgBean msgBean) {
        super.handlerMeg(msgBean);
    }

    @Override
    protected void onSuccess(int what, InfoResult t) {
        switch (what) {
        }
    }

    @Override
    protected void onFail(int what, InfoResult t) {
        switch (what) {
        }
    }

    @Override
    public void onDataState(int flag) {
        //1:没有网络 2:没有数据 3:获取数据失败 4:显示内容
        switch (flag) {
            case 1:
                if (loadService != null) {
                    loadService.showCallback(NoNetCallback.class);
                }
                break;
            case 2:
                if (loadService != null) {
                    loadService.showCallback(EmptyCallback.class);
                }
                break;
            case 3:
                if (loadService != null) {
                    loadService.showCallback(ErrorCallback.class);
                }
                break;
            case 4:
                if (loadService != null) {
                    loadService.showSuccess();
                }
                break;
            default:
                break;
        }
    }
}
